package com.example.demo.pojos;

import javax.persistence.*;
import java.sql.Date;
import java.util.Objects;

@Entity
public class Operation {
    private int oid;
    private String oName;
    private Date oTime;
    private User yh;

    @Id
    @Column(name = "oid", nullable = false)
    public int getOid() {
        return oid;
    }

    public void setOid(int oid) {
        this.oid = oid;
    }

    @Basic
    @Column(name = "oName", nullable = true, length = 20)
    public String getoName() {
        return oName;
    }

    public void setoName(String oName) {
        this.oName = oName;
    }

    @Basic
    @Column(name = "oTime", nullable = true)
    public Date getoTime() {
        return oTime;
    }

    public void setoTime(Date oTime) {
        this.oTime = oTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Operation operation = (Operation) o;
        return oid == operation.oid &&
                Objects.equals(oName, operation.oName) &&
                Objects.equals(oTime, operation.oTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(oid, oName, oTime);
    }

    @ManyToOne
    @JoinColumn(name = "uid", referencedColumnName = "uid")
    public User getYh() {
        return yh;
    }

    public void setYh(User yh) {
        this.yh = yh;
    }
}
